const { generateDynamicNews } = require('../../utils/data');

Page({
  data: {
    datas: []  // 存储动态新闻数据
  },

  onLoad: function() {
    // 调用 generateDynamicNews 函数生成动态新闻数据
    const datas = generateDynamicNews();
    console.log(datas);
    // 更新页面数据
    this.setData({ datas });
  },

  // 跳转到历史文献列表页面
  goToDocumentsList: function() {
    wx.navigateTo({
      url: '/pages/documentList/documentList',
    });
  },

  // 跳转到视频列表页面
  goToVideosList: function() {
    wx.navigateTo({
      url: '/pages/videoList/videoList',
    });
  },

  // 跳转到知识卡片列表页面
  goToKnowledgeCardsList: function() {
    wx.navigateTo({
      url: '/pages/knowledgeCardsList/knowledgeCardsList',
    });
  },

  // 跳转到推荐阅读列表页面
  goToRecommendedList: function() {
    wx.navigateTo({
      url: '/pages/recommendedList/recommendedList',
    });
  },

  // 点击进入详情
  viewDetails: function(event) {
    const id = event.currentTarget.dataset.id;  // 获取点击项的 ID
    wx.navigateTo({
      url: `/pages/library/detail/detail?id=${id}`,  // 跳转到详情页，并传递 ID
    });
  },
  // 处理点击更多按钮
  goToMorePage: function () {

      wx.showToast({
        title: '已加载全部数据',
        icon: 'none',
        duration: 2000,
      });
  }
  ,
  //下拉刷新
  onPullDownRefresh: async function () {
    console.log("开始下拉刷新");
    // await this.loadItems();
    wx.stopPullDownRefresh(); // 停止下拉刷新动画
    wx.showToast({
      title: '刷新完成',
      icon: 'success',
      duration: 2000
    });
  }
});
